﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
using System.Text;

namespace QTMusic.UserControls
{
    public partial class ControlButtons : System.Web.UI.UserControl
    {
        public string currentUser;

        public void BtnGotoPersonalPage(object sender, EventArgs e)
        {
            // TODO: Implement this method
            Response.Redirect("~/Websites/Profile.aspx");
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["QTCookie"];
            if (cookie != null && cookie["Name"] != null && cookie["ID"] != null)
            {
                currentUser = cookie["Name"];
                DataBind();
            }
        }

        protected void BtnLogout_Click(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["QTCookie"];
            if (cookie != null && cookie["Name"] != null && cookie["ID"] != null)
            {
                //xoa cookie
                HttpCookie newCookie = new HttpCookie("QTCookie");
                newCookie.Expires = DateTime.Now.AddYears(-1);
                //Replace old QTCookie with this new, expired cookie
                Response.Cookies.Add(newCookie);
                Response.Redirect("~/Websites/Default.aspx");
            }
        }
    }
}